#ifndef MODEL_HPP_INCLUDED
#define MODEL_HPP_INCLUDED

#include <GL/gl.h>

#include <boost/array.hpp>

#include <string>

#include "model_fwd.hpp"
#include "texture.hpp"
#include "wml_node_fwd.hpp"

namespace graphics
{

class model
{
public:
	static const_model_ptr get(const std::string& id);
	explicit model(wml::const_node_ptr node);

	void draw() const;

	typedef boost::array<GLfloat, 3> point;
	struct vertex {
		std::string id;
		point pos;
		boost::array<GLfloat, 2> uv;
	};

	struct triangle {
		boost::array<int, 3> points;
	};

	struct polygon {
		std::vector<int> points;
	};
private:
	void draw_vertex(int n) const;

	std::string id_;
	boost::array<GLfloat, 3> scale_;
	std::vector<vertex> vertices_;
	std::vector<triangle> triangles_;
	std::vector<polygon> polygons_;

	graphics::texture t_;
};

}

#endif
